<!doctype html>
<html>
<head>
    <title>{$backend_name}-{$code_name}</title>
    <meta name="description" content="">
    {include file="public/head"}
</head>
<body>
<!--header-->
{include file="public/header"}
<div class="tpl-page-container tpl-page-header-fixed">
    <!--menu-->
    {include file="public/menu"}
    <!--html body-->
    <div class="tpl-content-wrapper">
        <!--nav-->
        <div class="tpl-content-page-title">
            {$code_name}
        </div>
        <ol class="am-breadcrumb">
            <li><a href="{:url('index/index')}" class="am-icon-home">首页</a></li>
            <li><a href="{:url('active/index')}">活动</a></li>
            <li><a href="{:url('reward/index',['active_id'=>$active_id])}">奖品</a></li>
            <li class="am-active">{$code_name}</li>
        </ol>
        <!--content-->
        <div class="tpl-portlet-components">
            <div class="portlet-title">
                <div class="caption font-green bold">
                    <span class="am-icon-code"></span> {$code_name}列表
                </div>
                <!--<div class="tpl-portlet-input tpl-fz-ml">
                    <div class="portlet-input input-small input-inline">
                        <div class="input-icon right">
                            <i class="am-icon-search"></i>
                            <input type="text" class="form-control form-control-solid" placeholder="搜索..."></div>
                    </div>
                </div>-->
            </div>
            <div class="tpl-block">
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-md-12">
                        <div class="am-btn-toolbar">
                            <div class="am-btn-group am-btn-group-xs">
                                <div style="float: left;">
                                    按用户id:
                                    <input type="text" name="user_id" value="{$user_id}" style="border:1px solid rgb(169, 169, 169);"/>
                                    按用户昵称:
                                    <input type="text" name="nickname" value="{$nickname}" style="border:1px solid rgb(169, 169, 169);"/>

                                    按奖品:
                                    <select name="reward_id" class="span3">
                                        <option value="">--全部--</option>
                                        {foreach name="rewards" id="vo"}
                                        <option value="{$key}" {eq name="$reward_id" value="$key"}selected{/eq}>{$vo}</option>
                                        {/foreach}
                                    </select>

                                </div>
                                <div style="float: left;margin-left: 10px;">
                                    <a href="{:url($code.'/index',['active_id'=>$active_id])}" class="am-btn am-btn-default am-btn-primary search_btn">搜索</a>
                                    <a href="{:url($code.'/to_excel',['active_id'=>$active_id])}" class="am-btn am-btn-default am-btn-primary">导出表格</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="am-g" style="margin-top:20px;">
                    <div class="am-u-sm-12">
                        <form class="am-form">
                            <table class="am-table am-table-striped am-table-hover table-main">
                                <thead>
                                <tr>
                                    <!--<th class="table-check"><input type="checkbox" class="tpl-table-fz-check"></th>-->
                                    <th>#</th>
                                    <th>奖品名称</th>
                                    <th>中奖人员ID</th>
                                    <th>中奖人员昵称</th>
                                    <th>联系方式</th>
                                    <th>中奖时间</th>
                                    <th>领取时间</th>
                                    <th>兑换码</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {foreach $list as $vo}
                                <tr>
                                    <!--<td><input type="checkbox"></td>-->
                                    <td>{$vo.id}</td>
                                    <td>{$vo.reward.name}</td>
                                    <td>{$vo.user_id}</td>
                                    <td>{$vo.nickname}</td>
                                    <td>{$vo.mobile?:'(空)'}</td>
                                    <td>{$vo.create_time|date='Y-m-d H:i:s',###}</td>
                                    <td>
                                        {if condition="$vo.update_time"}
                                        {$vo.update_time|date='Y-m-d H:i:s',###}
                                        {else/}
                                        无
                                        {/if}
                                    </td>
                                    <td>{$vo.reward_code}</td>
                                    <td>
                                        <div class="am-btn-toolbar">
                                            <div class="am-btn-group am-btn-group-xs">
                                                {if condition="$vo.is_receive == 1"}
                                                已领取
                                                {else/}
                                                <a class="am-btn am-btn-default am-btn-xs am-text-secondary receive-btn"
                                                   href="{:url($code.'/receive',['id'=>$vo.id,'active_id'=>$vo.active_id])}">
                                                    <span class="am-icon-pencil-square-o"></span> 领取
                                                </a>
                                                {/if}
                                                <!--<button class="am-btn am-btn-default am-btn-xs am-hide-sm-only"><span class="am-icon-copy"></span> 复制</button>-->
                                                <!--<button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only"><span class="am-icon-trash-o"></span> 删除</button>-->
                                            </div>
                                        </div>

                                    </td>
                                </tr>
                                {/foreach}
                                </tbody>
                            </table>
                            <div class="am-cf">
                                <div class="am-fr">
                                    {$page}
                                </div>
                            </div>
                            <hr>

                        </form>
                    </div>
                </div>
            </div>
            <div class="tpl-alert"></div>
        </div>
    </div>
</div>
<!--js-->
{include file="public/js"}
<script type="text/javascript">
    $('.receive-btn').click(function(){
        var _this = $(this);
        if(confirm('确定已经领取么？')){
            var url = _this.attr('href');
            $.post(url,function(data){
                $.jGrowl(data.message);
                if(data.code == 0){
                    _this.remove();
                }
            },'json')
        }
        return false;
    });

    $('.search_btn').click(function(){
        var url = $(this).attr('href');
        var reward_id = $('select[name=reward_id]').val();
        var user_id = $('input[name=user_id]').val();
        var nickname = $('input[name=nickname]').val();
        location.href = url+'?active_id={$active_id}&reward_id='+reward_id+'&user_id='+user_id+'&nickname='+nickname;
        return false;
    });

    $('.excel_btn').click(function(){
        var url = $(this).attr('href');
        var reward_id = $('select[name=reward_id]').val();
        var user_id = $('input[name=user_id]').val();
        var nickname = $('input[name=nickname]').val();
        location.href = url+'?active_id={$active_id}&reward_id='+reward_id+'&user_id='+user_id+'&nickname='+nickname;
        return false;
    });
</script>
</body>
</html>